package org.esk.dablog.web.forms.system;

import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.ModelAndView;
import org.esk.dablog.service.StatisticsManager;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * This class implements "View External Referers" statistics.
 * Shows IP address, user name (if available) and referer string
 * if referer is not "novocycling.ru"
 * User: esk
 * Date: 27.12.2006
 * Time: 15:56:14
 * $Id:$
 */
public class ReferersForm extends ParameterizableViewController {
    private String localHostName;
    private StatisticsManager statisticsManager;


    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView result =  super.handleRequestInternal(request, response);
        result.addObject("stat", statisticsManager.listReferers("%"+ localHostName +"%"));
        return result;
    }

    public void setLocalHostName(String localHostName) {
        this.localHostName = localHostName;
    }


    public void setStatisticsManager(StatisticsManager statisticsManager) {
        this.statisticsManager = statisticsManager;
    }
}
